package com.sgb.kjwl.view.ui.adapter.pick;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.view.entity.HomeManageMenuEntity;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.recyclerview.adapter.PageRecycleAdapter;

import java.util.List;

public class PickMenuAdapter extends PageRecycleAdapter<HomeManageMenuEntity> {

    public PickMenuAdapter(Context context, List<HomeManageMenuEntity> datas) {
        super(context, R.layout.item_pick_menu, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, HomeManageMenuEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ImageView iv = holder.itemView.findViewById(R.id.iv);

        if (!TextUtils.isEmpty(entity.getIconUrl()) && entity.getIconUrl().contains("http")) {
            Glide.with(context).load(entity.getIconUrl() + "")
                    .apply(RequestOptions.bitmapTransform(new CircleCrop()).placeholder(R.mipmap.default_user))
                    .into(iv);
        }
    }
}
